#include <iostream>
#include <algorithm>
#include <vector>

using std::cout;
using std::endl;
using std::remove_if;
using std::for_each;
using std::vector;

void test()
{
    vector<int> vec = {1, 3, 5, 7, 5, 1, 3, 6};
    for_each(vec.begin(), vec.end(), [](int &value){
             cout << value << "  ";
             });
    cout << endl;

    cout << endl << endl;
    //这个是将所有小于5的删除，不符合题意，但是可以表明bind1st
    //可以与std::greater结合
    /* auto it = remove_if(vec.begin(), vec.end(), */ 
    /*                     bind1st(std::greater<int>(), 5)); */

    auto it = remove_if(vec.begin(), vec.end(), 
                        bind1st(std::less<int>(), 5));

    /* auto it = remove_if(vec.begin(), vec.end(), */ 
    /*                     bind2nd(std::greater<int>(), 5)); */

    /* auto it = remove_if(vec.begin(), vec.end(), [](int value){ */
    /*                     return value > 5; */
    /*                     }); */
    vec.erase(it, vec.end());
    for_each(vec.begin(), vec.end(), [](int &value){
             cout << value << "  ";
             });
    cout << endl;
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

